package com.gpframework.common.core.domain.model;

import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * 用户登录对象
 *
 * @Author gpframework
 */
public class LoginBody {
    /**
     * 用户名
     */
    @ApiModelProperty(value = "账号", example = "admin", required = true)
    private String username;

    /**
     * 品牌id
     */
    @ApiModelProperty(value = "品牌id", example = "1")
    private Long brandId;

    @ApiModelProperty("品牌编号")
    private String brandNo;

    /**
     * 门店idList
     */
    @ApiModelProperty(value = "门店idList")
    private List<Long> storeIdList;

    /**
     * 用户密码
     */
    @ApiModelProperty(value = "密码", example = "admin123", required = true)
    private String password;

    /**
     * 验证码
     */
    @ApiModelProperty(value = "验证码", example = "")
    private String code;

    /**
     * 唯一标识
     */
    @ApiModelProperty(value = "验证码唯一标识，调用获取验证码接口会下发这个值", example = "adjhkjdhjaajhjjk", required = true)
    private String uuid = "";

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Long getBrandId() {
        return brandId;
    }

    public void setBrandId(Long brandId) {
        this.brandId = brandId;
    }

    public List<Long> getStoreIdList() {
        return storeIdList;
    }

    public void setStoreIdList(List<Long> storeIdList) {
        this.storeIdList = storeIdList;
    }

    public String getBrandNo() {
        return brandNo;
    }

    public void setBrandNo(String brandNo) {
        this.brandNo = brandNo;
    }

    public void setStoreIdList(String storeIdList) {
        if (StringUtils.isEmpty(storeIdList)) {
            this.storeIdList = null;
            return;
        }
        String[] split = storeIdList.split(",");

        for (String id : split) {
            this.storeIdList.add(Long.parseLong(id));
        }
    }
}
